Clean up domain modeling and service logic#39
Merged
jeyongsong merged 9 commits intomainfrom Mar 17, 2026
Merged
Conversation
…vice and updating related components
…alue object and enhance payday resolution logic
…e with SalaryInputType for improved clarity and consistency
…d salary and earnings calculations
…age structure and clarity
…ogic simplification
…om update to validate for improved database integrity
Test Results49 tests 49 ✅ 0s ⏱️ Results for commit 65f167a. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Pull request overview
Major domain/service refactor to improve type-safety and encapsulation around payday handling, daily work status/event resolution, salary calculations, and notification entity organization.
Changes:
- Introduces
PaydayDay(@Embeddable) value object and migrates payday usage fromInt→PaydayDay. - Adds centralized resolution logic via
DailyWorkStatusType.resolve(...)andDailyEventType.resolve(...), refactoringWorkdayServiceto use them. - Moves notification entities into
com.moa.entity.notificationand refactors salary/earnings calculation into injectable calculator services.
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/resources/application-prod.yml | Changes prod Hibernate DDL behavior (update → validate). |
| src/main/kotlin/com/moa/entity/PaydayDay.kt | Adds payday value object with effective-date/weekend adjustment logic. |
| src/main/kotlin/com/moa/entity/Profile.kt | Replaces paydayDay: Int with embedded PaydayDay. |
| src/main/kotlin/com/moa/repository/ProfileRepository.kt | Updates payday query method to accept PaydayDay. |
| src/main/kotlin/com/moa/service/ProfileService.kt | Updates payday update/response mapping for PaydayDay. |
| src/main/kotlin/com/moa/service/OnboardingStatusService.kt | Updates onboarding response mapping for PaydayDay. |
| src/main/kotlin/com/moa/service/PaydayResolver.kt | Removes legacy payday resolver function. |
| src/main/kotlin/com/moa/entity/DailyWorkStatusType.kt | Adds resolve(...) to centralize daily status logic. |
| src/main/kotlin/com/moa/entity/DailyEventType.kt | Adds resolve(...) to centralize daily event resolution (payday). |
| src/main/kotlin/com/moa/service/WorkdayService.kt | Refactors to use new resolution methods and injected calculators. |
| src/main/kotlin/com/moa/service/calculator/SalaryCalculator.kt | Moves calculator to service package and converts from static object → Spring bean. |
| src/main/kotlin/com/moa/service/calculator/EarningsCalculator.kt | Moves to service package and injects SalaryCalculator. |
| src/main/kotlin/com/moa/service/notification/PaydayNotificationBatchService.kt | Refactors payday profile lookup to use PaydayDay.resolvingTo(...). |
| src/main/kotlin/com/moa/service/notification/NotificationMessageBuilder.kt | Updates imports to new notification/calculator packages. |
| src/main/kotlin/com/moa/service/notification/NotificationDispatchService.kt | Updates imports to moved notification entities. |
| src/main/kotlin/com/moa/service/notification/NotificationSyncService.kt | Updates imports to moved notification entities. |
| src/main/kotlin/com/moa/service/notification/NotificationSettingService.kt | Updates imports to moved notification entities. |
| src/main/kotlin/com/moa/service/notification/NotificationBatchService.kt | Updates imports for moved notification entities. |
| src/main/kotlin/com/moa/service/dto/NotificationSettingUpdateRequest.kt | Updates DTO import to moved NotificationSettingType. |
| src/main/kotlin/com/moa/service/dto/NotificationSettingResponse.kt | Updates DTO imports to moved notification entities. |
| src/main/kotlin/com/moa/repository/NotificationLogRepository.kt | Updates imports to moved notification entities. |
| src/main/kotlin/com/moa/repository/NotificationSettingRepository.kt | Updates imports to moved notification entities. |
| src/main/kotlin/com/moa/entity/notification/NotificationType.kt | Moves enum to com.moa.entity.notification. |
| src/main/kotlin/com/moa/entity/notification/NotificationStatus.kt | Moves enum to com.moa.entity.notification. |
| src/main/kotlin/com/moa/entity/notification/NotificationSettingType.kt | Moves enum to com.moa.entity.notification. |
| src/main/kotlin/com/moa/entity/notification/NotificationSetting.kt | Moves entity to com.moa.entity.notification. |
| src/main/kotlin/com/moa/entity/notification/NotificationLog.kt | Moves entity to com.moa.entity.notification. |
| src/main/kotlin/com/moa/entity/SalaryInputType.kt | Extracts SalaryInputType into its own file. |
| src/main/kotlin/com/moa/entity/PayrollVersion.kt | Removes nested SalaryInputType enum from this file. |
| src/test/kotlin/com/moa/entity/PaydayDayTest.kt | Adds unit tests for PaydayDay rules and effective-date logic. |
| src/test/kotlin/com/moa/entity/DailyWorkStatusTypeTest.kt | Adds unit tests for daily status resolution. |
| src/test/kotlin/com/moa/entity/DailyEventTypeTest.kt | Adds unit tests for daily event resolution (payday). |
| src/test/kotlin/com/moa/service/calculator/SalaryCalculatorTest.kt | Updates tests for new package/instance-based SalaryCalculator. |
| src/test/kotlin/com/moa/service/calculator/EarningsCalculatorTest.kt | Updates constructor usage to inject SalaryCalculator. |
| src/test/kotlin/com/moa/learning/fcm/FcmSendLearningTest.kt | Fixes test package declaration to match directory. |
Comments suppressed due to low confidence (1)
src/main/kotlin/com/moa/service/notification/PaydayNotificationBatchService.kt:63
candidatePaydayDaysis computed as aSet<PaydayDay>and passed intoProfileRepository.findAllByPaydayDayIn(...). If the repository method is changed to query on the embedded scalar (e.g.,paydayDay.value) for JPQL/provider compatibility, this call site should pass the correspondingIntvalues instead of embeddables to keep the batch query reliable.
private fun findPaydayProfiles(date: LocalDate): List<Profile> {
val candidatePaydayDays = PaydayDay.resolvingTo(date)
if (candidatePaydayDays.isEmpty()) {
return emptyList()
}
return profileRepository.findAllByPaydayDayIn(candidatePaydayDays)
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…and consistency in payday day handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a major refactor around payday handling and daily work status logic, shifting payday from a simple integer to a dedicated value object (
PaydayDay). It also adds richer event and status resolution for daily work schedules, and reorganizes notification-related entities into their own package. The changes improve type safety, encapsulation, and extensibility for future event types.Payday and daily event logic refactor:
PaydayDayvalue object to encapsulate payday logic, including effective payday calculation and weekend adjustment. All references to payday in entities and repositories now usePaydayDayinstead ofInt. (src/main/kotlin/com/moa/entity/PaydayDay.kt,src/main/kotlin/com/moa/entity/Profile.kt,src/main/kotlin/com/moa/repository/ProfileRepository.kt, [1] [2] [3]PaydayDay. (src/main/kotlin/com/moa/service/PaydayResolver.kt, src/main/kotlin/com/moa/service/PaydayResolver.ktL1-L17)PaydayDayobject, including validation and conversion for API responses. (src/main/kotlin/com/moa/service/ProfileService.kt, [1] [2] [3] [4] [5]Daily work status and event resolution:
DailyWorkStatusType.resolveandDailyEventType.resolvestatic methods to encapsulate business logic for determining work status and daily events, improving extensibility for future event types. (src/main/kotlin/com/moa/entity/DailyWorkStatusType.kt,src/main/kotlin/com/moa/entity/DailyEventType.kt, [1] [2]WorkdayServiceto use the new resolution methods for work status and events, replacing previous ad-hoc logic. (src/main/kotlin/com/moa/service/WorkdayService.kt, [1] [2] [3] [4]Notification entity reorganization:
notificationpackage, updating imports and repository usage accordingly for better modularity. (src/main/kotlin/com/moa/entity/notification/NotificationLog.kt,src/main/kotlin/com/moa/entity/notification/NotificationSetting.kt,src/main/kotlin/com/moa/entity/notification/NotificationSettingType.kt,src/main/kotlin/com/moa/entity/notification/NotificationStatus.kt,src/main/kotlin/com/moa/entity/notification/NotificationType.kt,src/main/kotlin/com/moa/repository/NotificationLogRepository.kt,src/main/kotlin/com/moa/repository/NotificationSettingRepository.kt, [1] [2] [3] [4] [5] [6] [7]Other improvements:
SalaryInputTypeenum to its own file for clarity and maintainability. (src/main/kotlin/com/moa/entity/SalaryInputType.kt, [1] [2]WorkdayServiceto use dependency injection forSalaryCalculatorinstead of static methods. (src/main/kotlin/com/moa/service/WorkdayService.kt, [1] [2] [3]These changes collectively improve the maintainability and extensibility of payday, daily event, and notification logic throughout the codebase.